package context

import (
	"Projects/CavaCloudSys/cavasmusrc/internal/common"
	"net/http"

        qflog "github.com/qf-tech/qftech-base/pkg/log"
	jsoniter "github.com/json-iterator/go"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/context"
)

type Context struct {
	iris.Context
}

var _ iris.Context = &Context{}

func (ctx *Context) Do(handlers context.Handlers) {
	context.Do(ctx, handlers)
}

func (ctx *Context) Next() {
	context.Next(ctx)
}

func (ctx *Context) JSON(v interface{}, options ...context.JSON) (int, error) {
	traceID := ctx.Request().Header.Get(common.TraceID)
	retMsg, _ := jsoniter.Marshal(v)
	ctx.StatusCode(http.StatusOK)
	qflog.Sugare.Infof("TraceID=%s|response data:%s", traceID, string(retMsg))
	return ctx.Context.JSON(v)
}
